//
//  testqrcode.swift
//  NJU QR
//
//  Created by 许煜恒 on 8/12.
//

import SwiftUI
import CoreImage.CIFilterBuiltins
import QRCode

struct testqrcode: View {
    var body: some View {
        VStack {
            Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
            GeometryReader{ geometry in
                Image(uiImage: generateQRCode(from: "hello", in: geometry.size)!)
            }
            
        }
    }
}

struct testqrcode_Previews: PreviewProvider {
    static var previews: some View {
        testqrcode()
    }
}

func generateQRCode(from string: String, in size:CGSize) -> UIImage? {
    let doc=QRCode.Document(data: string.data(using: .ascii)!, errorCorrection: .medium)
    let uii=doc.uiImage(size)
    return uii
}
